///*
// * Copyright (c) 2016. 恒昌互联网运营中心.
// */
//package com.credithc.eagleeye.agent.strategy;
//import com.alibaba.fastjson.JSON;
//import com.credithc.eagleeye.agent.bean.EagleEyeAgentConfig;
//import com.credithc.eagleeye.vo.RpcTraceInfoVo;
//import com.credithc.ice.eagleeye.service.EagleEyeIceServicePrx;
//import com.credithc.ice.eagleeye.service.EagleEyeIceServicePrxHelper;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.util.concurrent.atomic.AtomicBoolean;
///**
// * 描 述: <br/>
// * 作 者: zhangjin<br/>
// * 创 建：2016年09月26日<br/>
// * 版 本：v1.0.0<br>
// * <p/>
// * 历 史: (版本) 作者 时间 注释 <br/>
// */
//@Deprecated
//public class IceEagleEyeAgent extends  AbsEagleEyeAgent {
//    private transient static final Logger logger = LoggerFactory.getLogger(IceEagleEyeAgent.class);
//    private static AtomicBoolean initialized = new AtomicBoolean(false);
//    private volatile Ice.Communicator iceCommunicator ;
//
//    private final static String ENV_PRODUCT_LOCATOR_IP="10.100.14.71";
//    private final static String ENV_DLR_DEV_LOCATOR_IP="10.150.20.197";
//    private final static String ENV_DLR_TEST_LOCATOR_IP="10.150.20.198";
//    private final static String ENV_DLR_PRE_LOCATOR_IP="10.150.20.203";
//    private final static String ENV_DEV_LOCATOR_IP="10.150.24.11";
//
//    public IceEagleEyeAgent(EagleEyeAgentConfig eagleEyeAgentConfig) {
//        super(eagleEyeAgentConfig);
//        init();
//    }
//    private void init() {
//        if( initialized.compareAndSet(false, true) ){
//            logger.info("IceEagleEyeAgent init starting...");
//            String iceLocator = this.eagleEyeAgentConfig.getIceLocator();
//            if (iceLocator == null || iceLocator.length() == 0) {
//                throw new RuntimeException("IceEagleEyeAgent error:iceLocator is blank!");
//            }
//            String[] initParams = new String[] { "--Ice.Default.LocatorCacheTimeout="+this.eagleEyeAgentConfig.getIceLocatorCacheTimeout(),
//                    "--Ice.BackgroundLocatorCacheUpdates=1",
//                    "--Ice.Default.Package=com.credithc.ice",
//                    "--Ice.ACM.Client.Timeout=180",
//                    "--Ice.Default.Timeout=180",
//                    "--Ice.Default.Locator=" + iceLocator};
//            this.iceCommunicator = Ice.Util.initialize(initParams);
//
//            String ENV=eagleEyeAgentConfig.getAgentEnv();
//            if (StringUtils.isBlank(eagleEyeAgentConfig.getAgentEnv())) {
//                if(StringUtils.indexOf(eagleEyeAgentConfig.getIceLocator(),ENV_PRODUCT_LOCATOR_IP)>-1){
//                    ENV="product";
//                }else if(StringUtils.indexOf(eagleEyeAgentConfig.getIceLocator(),ENV_DEV_LOCATOR_IP)>-1){
//                    ENV="dev";
//                }else if(StringUtils.indexOf(eagleEyeAgentConfig.getIceLocator(),ENV_DLR_DEV_LOCATOR_IP)>-1){
//                    ENV="dev";
//                }else if(StringUtils.indexOf(eagleEyeAgentConfig.getIceLocator(),ENV_DLR_TEST_LOCATOR_IP)>-1){
//                    ENV="test";
//                }else if(StringUtils.indexOf(eagleEyeAgentConfig.getIceLocator(),ENV_DLR_PRE_LOCATOR_IP)>-1){
//                    ENV="pre";
//                }
//                eagleEyeAgentConfig.setAgentEnv(ENV);
//            }
//
//            logger.info("IceEagleEyeAgent init finished,iceLocator:"+iceLocator);
//        }
//    }
//
//    @Override
//    public boolean doSend2EagleEye(final RpcTraceInfoVo rpcTraceInfoVo) {
//        try {
//            String json= JSON.toJSONString(rpcTraceInfoVo);
//            getEagleEyeIceServicePrx().sendRpcTraceInfo(json);
//            logger.debug(String.format("send to eagleEye ice traceId:%s,rpcId:%s",rpcTraceInfoVo.getTraceId(),rpcTraceInfoVo.getRpcId()));
//            return true;
//        }catch (Exception ex){
//            logger.error(String.format("Ice方式发送鹰眼系统error:"+ex.getMessage()));
//        }
//        return false;
//    }
//
//    private EagleEyeIceServicePrx getEagleEyeIceServicePrx() {
//        if (this.iceCommunicator == null) {
//            throw new RuntimeException("eagle-ice配置未初始化");
//        }
//        Ice.ObjectPrx base = this.iceCommunicator.stringToProxy("EagleEyeIceService/eagleEyeIceService");
//        //不使用缓存连接，否则每次只连接到一个server上
//        base.ice_connectionCached(false);
//        EagleEyeIceServicePrx eagleEyeIceServicePrx= EagleEyeIceServicePrxHelper.uncheckedCast(base);
//        return  eagleEyeIceServicePrx;
//    }
//
//}
